package trism.game.controller.init {
	import trism.game.components.actions.GameAddToStageActionItem;
	import trism.game.components.actions.GameLoadConfigActionItem;
	import trism.game.components.actions.GameLoadLangActionItem;
	import trism.game.controller.GameBaseController;
	import trism.game.model.GameModel;

	import com.samoiloff.util.actions.ActionEvent;
	import com.samoiloff.util.actions.Actions;

	import flash.events.Event;

	/**
	 * @author Samoiloff  http://samoiloff.com/
	 */
	public class GameInitController extends GameBaseController {
		
		
		private var _actions : Actions;
		
		
		public function GameInitController(model : GameModel) {
			super(model);
			
			_actions = new Actions();
			
			_actions.addAction(new GameAddToStageActionItem(_model));
			_actions.addAction(new GameLoadConfigActionItem(_model));
			_actions.addAction(new GameLoadLangActionItem(_model));
			
			_actions.start();
			
			//trace("GameInitController.GameInitController() : ");

			_actions.addEventListener(ActionEvent.ACTIONS_COMPLETE, onActionsComplete);
		}
		
		private function onActionsComplete(e : Event) : void {
			_model.initialized = true;
		}
		
		override public function destroy() : void {
			_actions.destroy();
			_actions = null;
			
			
			super.destroy();
		}
		
	}
}
